﻿using System;
using System.Data;
using System.Text;

namespace LKCMS.Web
{
    public partial class Banner : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LKCMS.BLL.Adbanner bll = new LKCMS.BLL.Adbanner();
                DataTable dt = bll.GetList(11, "Aid=1 and IsLock=0 ", "SortId").Tables[0];
                StringBuilder sb = new StringBuilder();
                StringBuilder sb1 = new StringBuilder();
                StringBuilder sb2 = new StringBuilder();
                StringBuilder sb3 = new StringBuilder();
               

                sb.Append("<div id=focusPica>\n");
                sb.Append("<ul id=trNews>\n");

                sb3.Append("<SCRIPT>");
                sb3.Append("var focusCtr = new TabControl();\n");
                 sb3.Append("focusCtr.addRange($('trNews').getElementsByTagName('li'), [");
                 
              for(int i=0;i<dt.Rows.Count;i++)
              {
                  sb1.Append("<li id=t" + (i + 1) + "><a href=\"" + dt.Rows[i]["LinkUrl"].ToString() + "\" target=_blank>" + dt.Rows[i]["Title"].ToString() + "</a> </li>\n");
                  sb2.Append("<div class=\"pic\" id=\"s" + (i + 1) + "\">\n");
                  sb2.Append("<a href=\"" + dt.Rows[i]["LinkUrl"].ToString() + "\" target=_blank>\n");
                  sb2.Append("<img height=235 src=\"" + dt.Rows[i]["AdUrl"].ToString() + "\" width=950 border=0 alt=\"" + dt.Rows[i]["Title"].ToString() + "\"></a> </div>\n");
                 if (i == 0)
                 {
                     sb2.Append("<div class=clear></div>\n");
                  }
                  sb3.Append("'s"+(i+1+"'"));
                  if(i!=dt.Rows.Count-1)
                  {
                   sb3.Append(",");
                  }
                 

              }
              sb1.Append("</ul>\n");


              sb3.Append("]);\n");
                 sb3.Append("focusCtr.triggerType = \"mouseover\";\n");
                 sb3.Append("focusCtr.enableSlide = true;\n");
                 sb3.Append("focusCtr.slideInterval = 5000;\n");
                 sb3.Append("focusCtr.init();\n");
                 sb3.Append("</SCRIPT>");
                 sb.Append(sb1.ToString());
                 sb.Append(sb2.ToString());
                 sb.Append("</div>\n");
                 sb.Append(sb3.ToString());
                //sb.Append("</div>");

                this.LiteralAdbanner.Text = sb.ToString();

            }
        }
    }
}